package com.cxx.purchasecharge.dal;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import com.cxx.purchasecharge.core.model.persistence.User;
import com.cxx.purchasecharge.dal.common.GenericCRUDDao;

@Transactional
public interface UserDao extends GenericCRUDDao <User, Long>, UserDaoPlus
{

    Iterable <User> findAll (Sort sort);

    Page <User> findAll (Pageable pageable);

    public User findByUserId (String userId);

    @Modifying
    @Query ("update User u set u.pwd = ?2 where u.userId = ?1")
    public int updatePassword (String userId, String password);

    public User findByUserIdAndPwd (String userId, String pwd);
    
    @Query (value = "select u.id from User u where u.userId=?1")
    public long getUniqueIdByUserId(String userId);

}
